import pandas as pd

df = pd.DataFrame({'ID':[1,2,3],'Name':['Tim','Victor','Nick']}) #输入数据
df = df.set_index('ID') #已ID为索引
df.to_excel('C:/Users/LXL/Desktop/PandasVersusExcel/output.xlsx') #新建xlsx文件
print('Done!')